<template>
  <div class="container">
    <el-card shadow="always">
      <div class="list">
        <div class="item" v-for="item in list" :key="item.id">
          <div class="title">
            {{ item.systemType }}
          </div>
          <el-image
            v-for="url in item.URLList"
            :key="url"
            style="width: 150px; height: 150px"
            :src="url"
            fit="fill"
            :preview-src-list="item.urlList"
          ></el-image>
          <rz-height></rz-height>
          <div
            v-for="(url, index) in item.fileList"
            :key="url"
            class="enclosure"
            @click="$downloadFiles(url)"
          >
            附件{{ index + 1 }}
          </div>
        </div>
      </div>
          <el-empty description="暂无数据" v-if="!list.length"></el-empty>
    </el-card>
  </div>
</template>
<script>
import { QueryfoodSafetySystemList } from "@/api/modules/workstation";
export default {
  // props:[],
  // 页面加载
  created() {
    this.getList();
  },
  // 页面加载完成
  mounted() {},
  //实例销毁之前
  beforeDestroy() {},
  //实例销毁后
  destroyed() {},
  data() {
    return {
      list: [],
    };
  },
  // 方法
  methods: {
    getList() {
      QueryfoodSafetySystemList({ unitId: sessionStorage.getItem("workId") }).then(
        (res) => {
          res.data.forEach((item) => {
            item.fileList = [];
            item.URLList = [];
            item.urlList.forEach((x) => {
              if (x.match(/[^\.]\w*$/)[0] !== "pdf") {
                item.URLList.push(x);
              } else {
                item.fileList.push(x);
              }
            });
          });
          this.list = res.data;
        }
      );
    },
  },
  // 监听属性
  watch: {},
  // 组件
  components: {},
  // 计算属性
  computed: {},
};
</script>

<style lang="scss" scoped>
.container {
  .title {
    padding: 10px 0;
    font-size: $title;
  }
  .enclosure {
    color: $default;
    cursor: pointer;
    font-size: 16px;
  }
  /deep/ .el-image {
    margin-right: 10px;
  }
}
</style>
